/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view.main;
import model.game.GameEngine;
import model.game.InformationLayer;
import javax.swing.Timer;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import view.actor.Actors;

/**
 *
 * @author Satrio Dewantono
 */
public class DayTimer implements ActionListener{
  private Timer t_;
  private GameEngine game_;
  private int day;
  private InformationLayer il_;
  private boolean newday;
  private boolean tick;


  public DayTimer(GameEngine eng,Actors act){
    game_ = eng;
    day = 0;
    il_ = new InformationLayer(game_);
    t_ = new Timer(1000,this);
    t_.start();
  }

  public boolean isNewDay(){
    return newday;
  }

   public boolean tick(){
    return tick;
  }

  public void tickNewDayOK(){
    newday = false;
  }

  public void tickOK(){
    tick = false;
  }

  public void actionPerformed(ActionEvent e){
    if(!game_.isNight()){
      game_.advanceTimeDay();
    }else{
      game_.advanceTimeNight();
    }
    if (il_.getCurrentDay()>day){
      newday = true;
      day = il_.getCurrentDay();
    }
    tick = true;
  }
}
